package org.gis.mapserver.transform;

import java.io.Serializable;

/**
 *
 * @author gus
 */
public class Poligon implements Serializable
{
    private final static long serialVersionUID = 38475346369278345L;
    
    public final Point[] points;
    public final int length;

    public Poligon( Point[] points )
    {
        this.points = points;
        length = points.length;
    }

    public Poligon( double[] xpoints, double[] ypoints, double[] zpoints )
    {
        length = Math.min(Math.min(xpoints.length, ypoints.length), zpoints.length);
        points = new Point[length];
        for ( int i = 0; i < length; i++ )
        {
            points[i] = new Point(xpoints[i], ypoints[i], zpoints[i]);
        }

    }

    public Poligon( double[] xpoints, double[] ypoints )
    {
        length = Math.min(xpoints.length, ypoints.length);
        points = new Point[length];
        for ( int i = 0; i < length; i++ )
        {
            points[i] = new Point(xpoints[i], ypoints[i], 0.0);
        }
    }

    public double[] getXPoints()
    {
        double[] xpoints = new double[length];
        for ( int i = 0; i < length; i++ )
        {
            xpoints[i] = points[i].x;
        }
        return xpoints;
    }

    public double[] getYPoints()
    {
        double[] ypoints = new double[length];
        for ( int i = 0; i < length; i++ )
        {
            ypoints[i] = points[i].y;
        }
        return ypoints;
    }

    public double[] getZPoints()
    {
        double[] zpoints = new double[length];
        for ( int i = 0; i < length; i++ )
        {
            zpoints[i] = points[i].z;
        }
        return zpoints;
    }
}
